ref(core/opentelemetry): Move OTel span data inference from captureSpan to SentrySpanProcessor#21648
Conversation
…pan` to `SentrySpanProcessor`
size-limit report 📦
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 753ab1e. Configure here.
| if (client && hasSpanStreamingEnabled(client)) { | ||
| client.emit('afterSpanEnd', span); | ||
| if (this._client && hasSpanStreamingEnabled(this._client)) { | ||
| this._client.emit('afterSpanEnd', span); |
There was a problem hiding this comment.
Cached client breaks late init
Medium Severity
SentrySpanProcessor stores the client only in its constructor and uses that reference in onStart and onEnd instead of resolving the current client when spans finish. If the processor is created before Sentry.init() without a client option, _client stays undefined, so span streaming hooks and OTel backfill never run even after init.
Reviewed by Cursor Bugbot for commit 753ab1e. Configure here.
There was a problem hiding this comment.
I don't think this is an issue. We don't document initializing SentrySpanProcessor prior to initing a client. Our own SDK code also always inits a client prior to the processor and we can hand this off directly. If it turns out this is an issue, we can revert to the individual getClient calls but for now I wanna keep this optimized. Fwiw, this mimics behaviour in the non-POTel SDKs where spanStreamingIntegration orchestrates all of this. Integrations are also bound to the client that sets them up.
The less use we have of getClient() the better IMHO


This PR:
captureSpanto aprocessSpanhook onSentrySpanProcessor. The main benefit: ~0.5Kb bundle size reduction on browser and separation of concerns.spanKindhint toprocessSpanto makeinferSpanDatareturn the correct valuesotel.kindattribute previously present on transaction-sent spans (backfilling the attribute as deprecated to conventions in feat(attributes): Add deprecatedotel.kindattribute sentry-conventions#440)inferSpanData